Skip to content

Conversation

@garyrussell
Copy link
Contributor

Resolves #2702

When using asyncAcks with manual ack modes, the DefaultErrorHandler must have seekAfterError set to false; this required user configuration.

The framework now unconditionally sets the property when it configures a container using a manual ack mode.

In addition, the default DLT handler was not compatible with any manual ack mode, regardless of the asyncAcks setting.

Add Acknowledgment to the LoggingDltListenerHandlerMethod.

Also tested with reporter's reproducer.

cherry-pick to 2.9.x (will require instanceof polishing for Java 8)

Resolves spring-projects#2702

When using `asyncAcks` with manual ack modes, the `DefaultErrorHandler`
must have `seekAfterError` set to `false`; this required user configuration.

The framework now unconditionally sets the property when it configures a container
using a manual ack mode.

In addition, the default DLT handler was not compatible with any manual ack mode,
regardless of the `asyncAcks` setting.

Add `Acknowledgment` to the `LoggingDltListenerHandlerMethod`.

Also tested with reporter's reproducer.

**cherry-pick to 2.9.x (will require instanceof polishing for Java 8)**
invokeDelegateOnMessage(consumerRecord, acknowledgment, consumer);
Acknowledgment ack = acknowledgment;
if (ack == null) {
// The default DLT handler now requires an Acknowledgment.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I see it is @Nullable there. So, what is wrong to continue to use acknowledgment as it is?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of this

catch (org.springframework.messaging.converter.MessageConversionException ex) {
throw checkAckArg(acknowledgment, message, new MessageConversionException("Cannot handle message", ex));
}

and this

private RuntimeException checkAckArg(@Nullable Acknowledgment acknowledgment, Message<?> message, Exception ex) {
if (this.hasAckParameter && acknowledgment == null) {
return new ListenerExecutionFailedException("invokeHandler Failed",
new IllegalStateException("No Acknowledgment available as an argument, "
+ "the listener container must have a MANUAL AckMode to populate the Acknowledgment.",
ex));
}

I changed the reporter's reproducer to use default AckMode and hit this problem.

I didn't think it was worth it to remove the null check in the method, but I can do so if you insist,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm - maybe I could see if the parameter is annotated @Nullable and skip that check - will look at it tomorrow.

Copy link
Contributor Author

@garyrussell garyrussell Jun 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I would have to re-invoke the method in that case, since the invoke already failed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correction: I can check the nullability before the first invocation.

@artembilan artembilan merged commit bbefd04 into spring-projects:main Jun 14, 2023
@artembilan
Copy link
Member

It doesn't cherry-pick clearly: too many conflicts around deprecated utils over there in 2.9.x
Would you mind taking a look yourself, please?
Thanks

@garyrussell garyrussell deleted the GH-2702 branch June 14, 2023 15:41
@garyrussell
Copy link
Contributor Author

Back ported as 4401f96

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto Config Non-Blocking Retries with asyncAcks

2 participants